package com.zhouyibike.uu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhouyibike.uu.R;
import com.zhouyibike.uu.entity.PayYiQuanTypeResult;

import java.util.HashMap;
import java.util.List;

/**
 * Created by cc on 2017/5/3.
 */

public class YiQuanChongZhiListAdapter extends BaseAdapter {
    private Context context;
    private List<PayYiQuanTypeResult.DataBean> list;
    private HashMap<Integer,Boolean> presstag=new HashMap<>();

    public YiQuanChongZhiListAdapter(Context context, List<PayYiQuanTypeResult.DataBean> list) {
        this.context = context;
        this.list = list;
    }
    public void setpreid(int pressid){
        presstag.clear();
        presstag.put(pressid,true);
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(context).inflate(R.layout.item_chongzhilist,null);
        TextView textView= (TextView) convertView.findViewById(R.id.tv_itemchongzhi_p);
        if(presstag.containsKey(list.get(position).getId())){
            textView.setBackgroundResource(R.drawable.miaobian_bg_pressed);
            textView.setTextColor(context.getResources().getColor(R.color.radio_button_selected_color));
        }else{
            textView.setBackgroundResource(R.drawable.miaobian_bg_notpressed);
            textView.setTextColor(context.getResources().getColor(R.color.text_main_3));
        }
        if (list.get(position).getGivenCount()!=0)
        {
            textView.setText("充"+list.get(position).getPayCount()+"赠"+list.get(position).getGivenCount());
        }else{
            textView.setText(list.get(position).getPayCount());
        }
        convertView.setTag(list.get(position).getId());
        textView.setTag(list.get(position).getPayCount()+"");
        return convertView;
    }
}
